package cn.iocoder.yudao.module.alipay.dal.mysql.drawingaccount;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.alipay.dal.dataobject.drawingaccount.DrawingAccountDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.alipay.controller.admin.drawingaccount.vo.*;

/**
 * 收款账户 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface DrawingAccountMapper extends BaseMapperX<DrawingAccountDO> {

    default PageResult<DrawingAccountDO> selectPage(DrawingAccountPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DrawingAccountDO>()
                .eqIfPresent(DrawingAccountDO::getUserId, reqVO.getUserId())
                .eqIfPresent(DrawingAccountDO::getAccountType, reqVO.getAccountType())
                .likeIfPresent(DrawingAccountDO::getAccountName, reqVO.getAccountName())
                .eqIfPresent(DrawingAccountDO::getAccountNubmer, reqVO.getAccountNubmer())
                .eqIfPresent(DrawingAccountDO::getIsInvoicing, reqVO.getIsInvoicing())
                .eqIfPresent(DrawingAccountDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(DrawingAccountDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DrawingAccountDO::getId));
    }

    default List<DrawingAccountDO> selectList(DrawingAccountExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DrawingAccountDO>()
                .eqIfPresent(DrawingAccountDO::getUserId, reqVO.getUserId())
                .eqIfPresent(DrawingAccountDO::getAccountType, reqVO.getAccountType())
                .likeIfPresent(DrawingAccountDO::getAccountName, reqVO.getAccountName())
                .eqIfPresent(DrawingAccountDO::getAccountNubmer, reqVO.getAccountNubmer())
                .eqIfPresent(DrawingAccountDO::getIsInvoicing, reqVO.getIsInvoicing())
                .eqIfPresent(DrawingAccountDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(DrawingAccountDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DrawingAccountDO::getId));
    }

    default DrawingAccountDO getByUserId(String userId){
        return selectOne(new LambdaQueryWrapperX<DrawingAccountDO>().eq(DrawingAccountDO::getUserId,userId));
    };
}
